package day01_IO_JDBC.demo_JDBC_users.view;

import day01_IO_JDBC.demo_JDBC_users.Entity.Users;
import day01_IO_JDBC.demo_JDBC_users.controller.UsersController;

import java.util.Scanner;

public class UsersView {
    public static void main(String[] args) {
        System.out.println("输入1：注册操作");
        System.out.println("输入2：修改操作");

        Scanner scanner_in = new Scanner(System.in);
        int input= scanner_in.nextInt();
        try {
            while (true){
                switch (input){
                    case 1:

                        UsersController usersController = new UsersController();
                        Scanner scanner= new Scanner(System.in);
                        System.out.println("输入id：");
                        Integer id= scanner.nextInt();
                        System.out.println("输入用户名：");
                        String user_name= scanner.next();
                        System.out.println("输入密码：");
                        String pwd= scanner.nextLine();
                        System.out.println("输入手机号：");
                        String telphone= scanner.next();

                        Users users= new Users(user_name,pwd,id,telphone);
                        usersController.register(users);

                        break;

                    case 2:
                        UsersController usersController_update = new UsersController();
                        Scanner scanner_update= new Scanner(System.in);
                        System.out.println("输入需修改人员的id：");
                        Integer id_update= scanner_update.nextInt();
                        System.out.println("输入用户名：");
                        String user_name_update= scanner_update.next();
                        System.out.println("输入密码：");
                        String pwd_update= scanner_update.next();
                        System.out.println("输入手机号：");
                        String telphone_update= scanner_update.next();

                        Users users_update= new Users(user_name_update,pwd_update,id_update,telphone_update);
                        usersController_update.update(users_update);
                        break;
                }
                break;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}
